package com.example.demo.controller;

import com.example.demo.mapper.UserMapper;
import com.example.demo.model.ArticleInfo;
import com.example.demo.model.TestTable;
import com.example.demo.model.UserInfo;
import com.example.demo.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.Year;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 马拉圈
 * Date: 2023-08-09
 * Time: 19:42
 */



@RestController
public class TestController {

    @Autowired
    private TestService testService;

    @RequestMapping("/get_all")
    public List<UserInfo> getAll() {
        return testService.getAll();
    }

    @RequestMapping("/get_one")
    public UserInfo getOne(Integer id) {
        return testService.getOne(id);
    }

    @RequestMapping("/get_one_username")
    public UserInfo getOne(String username) {
        return testService.getOneByUsername(username);
    }

//    @Transactional sql回滚业务
    @RequestMapping("/test")
    public UserInfo test(UserInfo userInfo) {
        return userInfo;
    }

    @RequestMapping("/get_all2")
    public List<UserInfo> getAll2() {
        return testService.getAll2();
    }

    @RequestMapping("/login")
    public UserInfo login(String username, String password) {
        return testService.login(username, password);
    }

    @RequestMapping("/update")
    public int update(UserInfo userInfo) {
        return testService.update(userInfo);
    }

    @RequestMapping("/delete")
    public int delete(Integer state) {
        return testService.delete(state);
    }

    @RequestMapping("/insert")
    public int insert(UserInfo userInfo) {
        return testService.insert(userInfo);
    }

    @RequestMapping("/getDesc")
    public List<TestTable> getDesc() {
        return testService.getDesc();
    }

    @RequestMapping("/get_like")
    public List<UserInfo> getLike(String likeString) {
        return testService.getLike(likeString);
    }

    @RequestMapping("get_all3")
    public List<ArticleInfo> getAll3() {
        return testService.getAll3();
    }

    @RequestMapping("/get_articles")
    public UserInfo getArticles(Integer id) {
        return testService.getArticles(id);
    }

    @RequestMapping("/add")
    public Integer add(UserInfo userInfo) {
        return testService.add(userInfo);
    }

    @RequestMapping("/select1")
    public List<UserInfo> select1(UserInfo userInfo) {
        return testService.select1(userInfo);
    }

    @RequestMapping("/update2")
    public Integer update2(UserInfo userInfo) {
        return testService.update2(userInfo);
    }

    @RequestMapping("/delete2")
    public Integer delete2() {
        return testService.delete2();
    }

    @RequestMapping("/insert_users")
    public Integer insertUsers() {
        return testService.insertUsers();
    }
}
